/**
 * jQuery.defaultValue - gives default value/ watermark to input box and textareas.
 * @author Rohith Mohan
 * @version 0.1
 * @requires jquery 1.4
 * contact: facebook.com/mohanrohith
 *
 * @param {[string]} message This is an optional parameter. When set, message is used to set the default value. Default value is "Please enter"
 *
 * USAGE:
 * $('selector').defaultValue();
 * $('selector').defaultValue('watermark message');
 *
 * 
 */

(function($){
    $.fn.defaultValue =   function(message){
        var config  =   {
            value   :   'Please enter'
        }

        if(message) $.extend(config, {value : message});

       return this.each(function(){
            var incss   =   {
                'font-style'    : 'italic',
                'color'         :   '#aaaaaa',
                'font-weight'   :   'normal'
            };
            var nocss   =   {
                'font-style'    : $(this).css('font-style'),
                'color'         :   $(this).css('color'),
                'font-weight'   :   $(this).css('font-weight')
            };
            var typed   =   false;
            //var node    =   $(this)[0].nodeName.toLowerCase();
            //if( node == 'textarea' ){}

            if($(this).val()== "")  $(this).val(config.value).css(incss);

            $(this).bind({
                focusin   :   function(){
                    if($(this).val()== config.value && !typed){
                       $(this).val("").css(nocss);typed=true;
                    }  
                },

                focusout    :   function(){
                    if($(this).val()== "" && typed){
                       $(this).val(config.value).css(incss);typed = false;
                    }  
                }
            });
        });
    };
})(jQuery);